package com.ruoyi.web.controller.infectsnews;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.infectiousnews.domain.Infectiousnews;
import com.ruoyi.infectiousnews.service.IInfectiousnewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 传染病新闻热点Controller
 * 
 * @author ruoyi
 * @date 2024-07-06
 */
@RestController
@RequestMapping("/infectiousnews/infectiousnews")
public class InfectiousnewsController extends BaseController
{
    @Autowired
    private IInfectiousnewsService infectiousnewsService;

    /**
     * 查询传染病新闻热点列表
     */
    @PreAuthorize("@ss.hasPermi('infectiousnews:infectiousnews:list')")
    @GetMapping("/list")
    public TableDataInfo list(Infectiousnews infectiousnews)
    {
        startPage();
        List<Infectiousnews> list = infectiousnewsService.selectInfectiousnewsList(infectiousnews);
        return getDataTable(list);
    }

    /**
     * 导出传染病新闻热点列表
     */
    @PreAuthorize("@ss.hasPermi('infectiousnews:infectiousnews:export')")
    @Log(title = "传染病新闻热点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Infectiousnews infectiousnews)
    {
        List<Infectiousnews> list = infectiousnewsService.selectInfectiousnewsList(infectiousnews);
        ExcelUtil<Infectiousnews> util = new ExcelUtil<Infectiousnews>(Infectiousnews.class);
        util.exportExcel(response, list, "传染病新闻热点数据");
    }

    /**
     * 获取传染病新闻热点详细信息
     */
    @PreAuthorize("@ss.hasPermi('infectiousnews:infectiousnews:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infectiousnewsService.selectInfectiousnewsById(id));
    }

    /**
     * 新增传染病新闻热点
     */
    @PreAuthorize("@ss.hasPermi('infectiousnews:infectiousnews:add')")
    @Log(title = "传染病新闻热点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Infectiousnews infectiousnews)
    {
        return toAjax(infectiousnewsService.insertInfectiousnews(infectiousnews));
    }

    /**
     * 修改传染病新闻热点
     */
    @PreAuthorize("@ss.hasPermi('infectiousnews:infectiousnews:edit')")
    @Log(title = "传染病新闻热点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Infectiousnews infectiousnews)
    {
        return toAjax(infectiousnewsService.updateInfectiousnews(infectiousnews));
    }

    /**
     * 删除传染病新闻热点
     */
    @PreAuthorize("@ss.hasPermi('infectiousnews:infectiousnews:remove')")
    @Log(title = "传染病新闻热点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infectiousnewsService.deleteInfectiousnewsByIds(ids));
    }
}
